function flag = check_inside_pml(i,j,nx,ny,no_of_lyr,nlyr)
flag = false;
nghost = 2;
npml = 25; % 25层PML
if (i<=npml+nghost)
    flag = true;
end
if ((nx-i)<npml+nghost)
    flag = true;
end
if (no_of_lyr == nlyr)
    if ((ny-j)<npml+nghost)
        flag = true;
    end
end
end